package cc.catface.api.business.app;

import cc.catface.common.output.ResultBody;
import cc.catface.dao.app.pojo.article.dto.ApArticleListInputDTO;
import cc.catface.dao.app.pojo.article.pojo.ApArticle;
import cc.catface.service.app.article.ApArticleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("article")
@Api(tags = "[移动]文章信息")
public class ApArticleController {
    @Autowired
    private ApArticleService articleService;

    @ApiOperation("新增文章")
    @PostMapping("add")
    public ResultBody add(@RequestBody ApArticle article) {
        return articleService.add(article);
    }

    @ApiOperation("查询所有文章")
    @GetMapping("list")
    public ResultBody list(ApArticleListInputDTO in) {
        return articleService.list(in);
    }

    @ApiOperation("查看文章消息内容")
    @GetMapping("getContent")
    public ResultBody getContent(long id) {
        return articleService.getContent(id);
    }

    @ApiOperation("更新文章信息(根据id)")
    @PostMapping("update")
    public ResultBody update(@RequestBody ApArticle article) {
        return articleService.update(article);
    }
}
